//
//  XXDetailViewController.m
//  XX
//
//  Created by lly on 15/5/26.
//  Copyright (c) 2015年 lly. All rights reserved.
//

#import "XXDetailViewController.h"
#import "UIViewExt.h"
#import "AppMacro.h"
@interface XXDetailViewController ()
@property (strong, nonatomic) IBOutlet NSLayoutConstraint *webConstraint;

@end

int i = 0;
@implementation XXDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.webView.scalesPageToFit = YES;
    NSString *htmlString = @"<html><head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\"\/><style>html{overflow-y:scroll;}body{margin:0;padding:0;font:12px\/1.5 '\u5fae\u8f6f\u96c5\u9ed1',Arial,sans-serif;position:relative;}img{width:100%;height:auto;}<\/style><\/head><body><img src=\"http:\/\/imgcdn.xuxian.com\/upload\/2015\/05\/18\/20150518052843136.jpg\" alt=\"\" \/><img src=\"http:\/\/imgcdn.xuxian.com\/upload\/2015\/05\/18\/20150518052850978.jpg\" alt=\"\" \/><img src=\"http:\/\/imgcdn.xuxian.com\/upload\/2015\/05\/18\/20150518052855621.jpg\" alt=\"\" \/><img src=\"http:\/\/imgcdn.xuxian.com\/upload\/2015\/05\/18\/20150518052900652.jpg\" alt=\"\" \/><img src=\"http:\/\/imgcdn.xuxian.com\/upload\/2015\/05\/18\/20150518052906482.jpg\" alt=\"\" \/><\/body><\/html>";
    [self.webView loadHTMLString:htmlString baseURL:nil];
    [self performSelector:@selector(viewDidLayoutSubviews) withObject:nil afterDelay:1];
    
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidLayoutSubviews
{
    [super viewDidLayoutSubviews];
    NSLog(@"fas");
    CGSize size = [self.webView sizeThatFits:CGSizeMake(SCREEN_WIDTH, 10000)];

    CGFloat contentSizeHeight = self.contentView.height + self.centerView.height + 35 +  size.height;
    self.webConstraint.constant = size.height;
    self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH, contentSizeHeight);
    self.scrollView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    

    if( i <10 )
    {
        [self performSelector:@selector(viewDidLayoutSubviews) withObject:nil afterDelay:1];
        i++;
    }


}
- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    NSLog(@"%@",NSStringFromCGRect(self.webView.frame));
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [self viewDidLayoutSubviews];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
